package com.developer.platform.domain.service.impl;

import com.developer.platform.domain.DictData;
import com.developer.platform.domain.DictType;
import com.developer.platform.domain.repository.IDictRepository;
import com.developer.platform.domain.service.IDictService;
import org.springframework.stereotype.Service;

/**
 * @author ：qiaoliang
 * @date ：2020-11-09
 */
@Service
public class DictServiceImpl implements IDictService {

    private final IDictRepository dictRepository;

    public DictServiceImpl(IDictRepository dictRepository) {
        this.dictRepository = dictRepository;
    }

    @Override
    public void saveType(DictType dictType) {
        dictRepository.saveType(dictType);
        this.deleteData();
    }

    @Override
    public void saveData(DictData dictData) {
        dictRepository.saveData(dictData);
        this.deleteData();
    }

    @Override
    public void updateType(DictType dictType) {
        dictRepository.updateType(dictType);
        this.deleteData();
    }

    @Override
    public void updateData(DictData dictData) {
        dictRepository.updateData(dictData);
        this.deleteData();
    }

    @Override
    public void deleteType(String type) {
        dictRepository.deleteType(type);
        this.deleteData();
    }

    @Override
    public void deleteData(Long id) {
        dictRepository.deleteData(id);
        this.deleteData();
    }
}
